package com.liuhaozzu.messageq.rabbitmq;

import java.io.IOException;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class SendVhost {

	private static final String QUEUE_NAME="quname";
	public static void main(String[] args) throws IOException {
		ConnectionFactory factory=new ConnectionFactory();
		factory.setHost("192.168.91.152");
		factory.setVirtualHost("test");
		factory.setUsername("liuhaozzu");
		factory.setPassword("liuhao1989");
		factory.setPort(5672);
		
		Connection conn=factory.newConnection();
		Channel channel = conn.createChannel();
		channel.queueDeclare(QUEUE_NAME, false, false, false, null);
		String message="test_from_liuhaozzu";
		channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
		System.out.println("[X] sent:'" +message+"'");
		channel.close();
		conn.close();
	}

}
